# Maintainer: Maxime Gauduin <alucryd@archlinux.org>
# Contributor: Guillaume Alaux <guillaume@archlinux.org>
# Contributor: William Gathoye <william+archlinux@gathoye.be>
# Contributor: Emanuel Couto <emanuel.amaral.couto@gmail.com>
# Contributor: Richard Jackson <rdjack21@gmail.com>
# Contributor: Tinx <arch@tinx.eu>
# Contributor: Jens Kapitza <j.kapitza@schwarze-allianz.de>
# Contributor: Olli <olli@coderkun.de>

pkgbase=java11-openjfx
pkgname=(
  java11-openjfx
  java11-openjfx-doc
  java11-openjfx-src
)
pkgver=11.0.10.u1
pkgrel=1
pkgdesc='Java OpenJFX 11 client application platform (open-source implementation of JavaFX)'
arch=(x86_64)
url=https://wiki.openjdk.java.net/display/OpenJFX/Main
license=(custom)
makedepends=(
  alsa-lib
  ant
  cairo
  cmake
  ffmpeg
  freetype2
  gdk-pixbuf2
  glib2
  gperf
  gtk2
  gtk3
  java-environment-openjdk=11
  libgl
  libx11
  libxtst
  pango
  python
  ruby
  unzip
  webkit2gtk
  zip
)
source=(
  https://hg.openjdk.java.net/openjfx/11-dev/rt/archive/${pkgver//.u/+}.tar.bz2
  gradle.properties
  https://services.gradle.org/distributions/gradle-4.8-bin.zip
  java11-openjfx-flags.patch
  java11-openjfx-no-xlocale.patch
  java11-openjfx-gstreamer-lite-gcc10-compat.patch
)
b2sums=('6bc1970151dae82595f23c90a5aabdb4fb86e683b7f896e59638e4710f614a61f98fe75843914a92ac57509826e7abff6980eab5fcb4de1ecd42c974025ed2b8'
        'a77fd8814a5978827de01a652f7b945f3439df04606434ced8998c8d77a82985292490e6965299aeb52f9da3d8069b4091d75519bd4ec8a15f70bc6d28b13498'
        'eb6592afe122690f5e013abec2821beabac070563556ceec67ce02506582d4d9ac9c5d9f97ad2c464e442446f26ff90e9ead2c04e462a564411259564e3332c6'
        '27f0bd59d53f3882e5226480c7763de04bb909af0863e8868fe92cc5906e5f8bdec71e04d366f300f9f4071c8791fb730d8a435136bc327e44d8065e4ae96ee3'
        '13216615c01b8d48d17889ffa22668c38568870d83ab30c542eb5b5620db305f02efb1acb99d9b5e89eb0a73a134bb336cb301f4de4e8855cae50efb099e384e'
        '119fa1cc5da2cdefa22bbe9b6f76581faa74e05fa7b6e5576470fc0251c6e257f122fbba03754cc01f7c7251145cfa1cab4ffc2f9d59ff0c175a121e943a0f64')

prepare() {
  cd rt-${pkgver//.u/+}

  ln -sf ../gradle.properties .
  patch -Np1 -i ../java11-openjfx-flags.patch
  patch -Np1 -i ../java11-openjfx-no-xlocale.patch
  patch -Np1 -i ../java11-openjfx-gstreamer-lite-gcc10-compat.patch
}

build() {
  cd rt-${pkgver//.u/+}

  ../gradle-4.8/bin/gradle zips
}

package_java11-openjfx() {
  depends=(
    java-runtime-openjdk=11
    libgl
    libx11
    libxtst
  )
  optdepends=(
    'ffmpeg: Media support',
    'gtk2: GTK2 support',
    'gtk3: GTK3 support',
    'webkit2gtk: Web support'
  )
  provides=('java-openjfx=11')

  cd rt-${pkgver//.u/+}

  install -dm 755  "${pkgdir}"/usr/{lib/jvm/java-11-openjfx,share/licenses}
  cp -dr --no-preserve=ownership build/sdk/lib "${pkgdir}"/usr/lib/jvm/java-11-openjfx/
  rm "${pkgdir}"/usr/lib/jvm/java-11-openjfx/lib/src.zip
  cp -dr --no-preserve=ownership build/jmods "${pkgdir}"/usr/lib/jvm/java-11-openjfx/
  cp -dr --no-preserve=ownership build/sdk/legal "${pkgdir}"/usr/share/licenses/java11-openjfx
}

package_java11-openjfx-doc() {
  cd rt-${pkgver//.u/+}

  install -dm 755 "${pkgdir}"/usr/share/{doc,licenses}
  cp -dr --no-preserve=ownership build/javadoc "${pkgdir}"/usr/share/doc/java11-openjfx
  ln -s java11-openjfx "${pkgdir}"/usr/share/licenses/java11-openjfx-doc
}

package_java11-openjfx-src() {
  cd rt-${pkgver//.u/+}

  install -dm 755  "${pkgdir}"/usr/{lib/jvm/java-11-openjfx,share/licenses}
  install -m 644 build/sdk/lib/src.zip "${pkgdir}"/usr/lib/jvm/java-11-openjfx/javafx-src.zip
  ln -s java11-openjfx "${pkgdir}"/usr/share/licenses/java11-openjfx-src
}

# vim: ts=2 sw=2 et:
